<script setup>
import { defineProps, defineEmits } from 'vue'

const props = defineProps({
  menuItems: Array,
  currentPage: String
})
const emit = defineEmits(['page-change', 'new-chat', 'show-history'])
</script>

<template>
  <nav class="flex flex-col h-[calc(100vh-8rem)] bg-white rounded-lg shadow-md">
    <div class="flex-1 overflow-y-auto">
      <div class="p-4 border-b border-gray-100">
        <h2 class="text-xl font-bold text-gray-800">功能菜单</h2>
      </div>
      <div class="p-3 space-y-3">
        <button
          v-for="item in menuItems"
          :key="item.id"
          class="w-full flex items-center gap-4 p-3 rounded-xl text-gray-700 hover:bg-gray-50 transition-all duration-300 transform hover:scale-105 hover:shadow-md"
          :class="{ 'bg-blue-50 text-blue-700 shadow-md scale-105': currentPage === item.id }"
          @click="emit('page-change', item.id)"
        >
          <div :class="['w-14 h-14 rounded-xl flex items-center justify-center text-white shadow-md transform transition-all duration-300', item.color]">
            <i :class="['fa', item.icon, 'text-2xl']"></i>
          </div>
          <span class="font-medium text-lg">{{ item.name }}</span>
        </button>
      </div>
    </div>
    <!-- 新建对话和历史对话按钮固定在底部 -->
    <div class="p-3 border-t border-gray-100">
      <div class="flex flex-col gap-2">
        <button
          class="w-full flex items-center gap-3 px-4 py-3 rounded-xl bg-blue-50 hover:bg-blue-100 text-blue-700 font-medium transition-all duration-300 hover:shadow-md hover:scale-105"
          @click="emit('new-chat')"
        >
          <i class="fas fa-plus text-xl"></i>
          <span class="text-lg">新建对话</span>
        </button>
        <button
          class="w-full flex items-center gap-3 px-4 py-3 rounded-xl bg-gray-50 hover:bg-gray-100 text-gray-700 font-medium transition-all duration-300 hover:shadow-md hover:scale-105"
          @click="emit('show-history')"
        >
          <i class="fas fa-history text-xl"></i>
          <span class="text-lg">历史对话</span>
        </button>
      </div>
    </div>
  </nav>
</template>

<style scoped>
nav {
  position: sticky;
  top: 2rem;
}

/* 自定义滚动条样式 */
.overflow-y-auto {
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

.overflow-y-auto::-webkit-scrollbar {
  width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-track {
  background: transparent;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
  background-color: rgba(156, 163, 175, 0.5);
  border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
  background-color: rgba(156, 163, 175, 0.7);
}

/* 添加菜单项悬停动画 */
button {
  position: relative;
  overflow: hidden;
}

button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.5);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%, -50%);
  transform-origin: 50% 50%;
}

button:hover::after {
  animation: ripple 1s ease-out;
}

@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 0.5;
  }
  100% {
    transform: scale(20, 20);
    opacity: 0;
  }
}
</style> 